<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>银行卡</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <link rel="shortcut icon" href="__PUBLIC__/admin/favicon.ico">
    <link href="__PUBLIC__/admin/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/js/spectrum/spectrum.css">
    <link href="__PUBLIC__/admin/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="__PUBLIC__/admin/css/animate.css" rel="stylesheet">
    <link href="__PUBLIC__/admin/css/style.css?v=4.1.0" rel="stylesheet">
    <link href="__PUBLIC__/admin/js/plugins/fancybox/jquery.fancybox.css" rel="stylesheet">
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>信用查-<small>银行卡</small></h5>
                </div>
                <div class="ibox-content">
                    <form method="post" class="form-horizontal" onsubmit="return false">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">*姓名</label>
                            <div class="col-sm-10">
                                <input type="text" style="width:50%"  class="form-control" value="<{$bank_msg.username}>" id="username" name="username" placeholder="持卡人姓名" <if condition="$bank_msg['username'] neq ''">readonly</if> >
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">*手机号</label>
                            <div class="col-sm-10">
                                <input type="number" style="width:50%" min="0" class="form-control" value="<{$bank_msg.mobile}>" id="mobile" name="mobile" placeholder="持卡人手机号" <if condition="$bank_msg['mobile'] neq ''">readonly</if> >
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">*银行卡号</label>
                            <div class="col-sm-10">
                                <input type="number" style="width:80%" min="0" class="form-control" value="<{$bank_msg.bank_number}>" id="bank_number" name="bank_number" placeholder="银行卡号" <if condition="$bank_msg['bank_number'] neq ''">readonly</if> >
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">*银行卡类型</label>
                            <div class="col-sm-10">
                                <select name="bank_card_type" id="bank_card_type" class="form-control m-b"  style="margin-bottom: 0;padding-top: 3px;display: inline;width: 50%;" >
                                    <option value="1" <if condition="$bank_msg['bank_card_type'] eq 1">selected</if> >借记卡</option>
                                    <option value="2" <if condition="$bank_msg['bank_card_type'] eq 2">selected</if>>信用卡</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">*所属银行</label>
                            <div class="col-sm-10">
                                <select name="bank_code" id="bank_code" class="form-control m-b"  style="margin-bottom: 0;padding-top: 3px;display: inline;width: 50%;" >
                                    <volist name="bank_code" id='v'>
                                        <option value="<{$v.bank_code}>" <if condition="$bank_msg['bank_code'] eq $v['bank_code']">selected</if> ><{$v.bank_name}></option>
                                    </volist>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">*银行具体名称</label>
                            <div class="col-sm-10">
                                <input type="text" style="width:80%" class="form-control" value="<{$bank_msg.create_bank}>" id="create_bank" name="create_bank" placeholder="比如中国建设银行股份有限公司XXXX支行" <if condition="$bank_msg['create_bank'] neq ''">readonly</if> >
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-2">
                                <if condition="$bank_msg eq ''">
                                    <button class="btn btn-primary" type="button" id="sub">保存</button>
                                </if> 
                                <button class="btn btn-white" type="button" onclick="javascript :history.back(-1);">返回</button>
                            </div>
                        </div>
                    </form>

                </div>
            </div>
        </div>
    </div>
</div>


<script src="__PUBLIC__/admin/js/spectrum/docs/jquery-2.1.0.js"></script>
<script src="__PUBLIC__/admin/js/bootstrap.min.js?v=3.3.6"></script>
<script src="__PUBLIC__/admin/js/layer/layer.js"></script>
<script src="__PUBLIC__/admin/js/layui/layui.js"></script>
<script type="text/javascript" src="__PUBLIC__/admin/js/spectrum/spectrum.js"></script>
<script type='text/javascript' src='__PUBLIC__/admin/js/spectrum/docs/toc.js'></script>
<script type='text/javascript' src='__PUBLIC__/admin/js/spectrum/docs/docs1.js'></script>
<script src="__PUBLIC__/admin/js/content.js?v=1.0.0"></script>
<script src="__PUBLIC__/admin/js/plugins/fancybox/jquery.fancybox.js"></script>
<script src="__PUBLIC__/admin/js/ajaxfileupload.js"></script>
<script>
    var url="__MODULE__/Finance/bind_bank";
    //提交
    $('#sub').on('click',function(){
            var username =$("#username").val();
            var mobile =$("#mobile").val();
            var bank_number =$("#bank_number").val();
            var create_bank =$("#create_bank").val();
            var bank_code = $("#bank_code option:selected").val();
            var bank_card_type = $("#bank_card_type option:selected").val();
            if(username == '' || mobile == '' || bank_number == '' || create_bank == '') {
                layer.alert('请将信息填写完整',{icon:5,time:2000});                
                return false;
            }
            if(!(/^1[34578]\d{9}$/.test(mobile))){ 
                layer.alert("手机号码有误，请重填");  
                return false; 
            } 
            if(bank_number.length < 16 || bank_number.length > 19) {
                layer.alert('银行卡号长度必须在16到19之间',{icon:5,time:2000});                
                return false;
            }
            //开头6位
            var strBin = "10,18,30,35,37,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,58,60,62,65,68,69,84,87,88,94,95,98,99";
            if(strBin.indexOf(bank_number.substring(0, 2)) == -1) {
                layer.alert('银行卡号开头6位不符合规范',{icon:5,time:2000});                
                return false;
            }

            op=1
            $.post('__MODULE__/Finance/bind_bank',{username:username,mobile:mobile,bank_number:bank_number,create_bank:create_bank,bank_code:bank_code,bank_card_type:bank_card_type},function(data){
                // console.log(data);return;
                if(data.code=='1001'){
                    layer.alert(data.result, {title: '提示框', icon: 1}, function (index) {
                        layer.close(index);
                        window.location.href = '__MODULE__/Finance/bind_bank';
                    });
                }else{
                    if(data.status=='0'){
                        layer.alert(data.info);
                    }else{
                        layer.alert(data.result);
                    }
                }
            });
    });
    

</script>
</body>
</html>
